package com.sqfw.project.wp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.project.wp.domain.WpBackInfo;
import com.sqfw.project.wp.service.IWpBackInfoService;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.web.page.TableDataInfo;

/**
 * 工单退回表Controller
 * 
 * @author lx
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/wp/wp_back_info")
public class WpBackInfoController extends BaseController
{
    @Autowired
    private IWpBackInfoService wpBackInfoService;

    /**
     * 查询工单退回表列表
     */
    @PreAuthorize("@ss.hasPermi('wp:wp_back_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(WpBackInfo wpBackInfo)
    {
        startPage();
        List<WpBackInfo> list = wpBackInfoService.selectWpBackInfoList(wpBackInfo);
        return getDataTable(list);
    }

    /**
     * 导出工单退回表列表
     */
    @PreAuthorize("@ss.hasPermi('wp:wp_back_info:export')")
    @Log(title = "工单退回表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpBackInfo wpBackInfo)
    {
        List<WpBackInfo> list = wpBackInfoService.selectWpBackInfoList(wpBackInfo);
        ExcelUtil<WpBackInfo> util = new ExcelUtil<WpBackInfo>(WpBackInfo.class);
        util.exportExcel(response, list, "工单退回表数据");
    }

    /**
     * 获取工单退回表详细信息
     */
    @PreAuthorize("@ss.hasPermi('wp:wp_back_info:query')")
    @GetMapping(value = "/{scid}")
    public AjaxResult getInfo(@PathVariable("scid") String scid)
    {
        return success(wpBackInfoService.selectWpBackInfoByScid(scid));
    }

    /**
     * 新增工单退回表
     */
    @PreAuthorize("@ss.hasPermi('wp:wp_back_info:add')")
    @Log(title = "工单退回表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WpBackInfo wpBackInfo)
    {
        return toAjax(wpBackInfoService.insertWpBackInfo(wpBackInfo));
    }

    /**
     * 修改工单退回表
     */
    @PreAuthorize("@ss.hasPermi('wp:wp_back_info:edit')")
    @Log(title = "工单退回表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WpBackInfo wpBackInfo)
    {
        return toAjax(wpBackInfoService.updateWpBackInfo(wpBackInfo));
    }

    /**
     * 删除工单退回表
     */
    @PreAuthorize("@ss.hasPermi('wp:wp_back_info:remove')")
    @Log(title = "工单退回表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scids}")
    public AjaxResult remove(@PathVariable String[] scids)
    {
        return toAjax(wpBackInfoService.deleteWpBackInfoByScids(scids));
    }


}
